package com.dyh.quickdemo.bizDemo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.util.StringUtils;

/*
@Author=Joey Wheeler
@Date=2020/11/19 10:34
*/
@Slf4j
public class adwawd {

    @Test
    public void test2(){
        String reason1 = "r1";
        String reason2 = "";
        String reason3 = "r3";
        StringBuffer tdlineBuff = new StringBuffer();
        if (!StringUtils.isEmpty(reason1))
            tdlineBuff.append(reason1);
        else if (!StringUtils.isEmpty(reason2))
            tdlineBuff.append(reason2);

        if (!StringUtils.isEmpty(reason3)){
            if (tdlineBuff.length()>0)
                tdlineBuff.append("。").append(reason3);
            else
                tdlineBuff.append(reason3);
        }
        System.out.println(tdlineBuff.toString());
    }



    @Test
    public void test1(){
        StringBuffer stringBuffer = new StringBuffer();
        String s1 = "";
        String s2 = "s2";
        stringBuffer.append(StringUtils.isEmpty(s1)?StringUtils.isEmpty(s2)?"":s2:s1);

        System.out.println(stringBuffer);
    }

    @Test
    public void test(){
        try {
            fun();
        } catch (Exception e) {
            log.error("外部捕捉到异常e=",e);
        }
    }

    public void fun(){

        final Runnable r = ()->{
            if (1==1)
                throw new RuntimeException("1==1");
        };

        r.run();
    }




}
